/*
 * @Author: 闫聪敏
 * @Email: 
 * @Date: 2020-03-02 10:20:42
 * @Descripttion: 
 */
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from "@angular/common/http";
import { Observable, of } from "rxjs";
import { tap } from 'rxjs/operators';
@Injectable({
  providedIn: 'root'
})
export class ApplyWareService {

  constructor(
    private http: HttpClient
  ) { }
  //#region 入库申请
  //列表
  private pageListUrl = '/api/materialInoutReq'
  apiList(data): Observable<any> {
    let _dataJson = {
      params: {
        ...data
      }
    }
    return this.http.get(this.pageListUrl, _dataJson).pipe();
  }
  //新加
  private addUrl = '/api/materialInoutReq/in'
  add(data): Observable<any> {
    let _dataJson = data
    return this.http.post(this.addUrl, _dataJson).pipe();
  }
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-06 09:49:34
   * @Descripttion:修改 
   * @Return: 
   */
  private editUrl = '/api/materialInoutReq/edit_in'
  edit(data, id): Observable<any> {
    var url = this.editUrl + "/" + id;
    let _dataJson = data
    return this.http.put(url, _dataJson).pipe();
  }
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-06 09:49:27
   * @Descripttion:删除 
   * @Return: 
   */
  private delSpecUrl = '/api/materialInoutReq'
  del(data): Observable<any> {
    let _dataJson = {
      headers: new HttpHeaders({
        'Content-Type': 'application/json',
      }),
      body: data
    }
    return this.http.delete(this.delSpecUrl, _dataJson).pipe();
  }
  private modelUrl = '/api/materialInoutReq/detail';
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-06 09:49:18
   * @Descripttion: 获取明细
   * @Return: 
   */
  GetModel(data): Observable<any> {
    let _dataJson = {
      params: {
        ...data
      }
    }
    return this.http.get(this.modelUrl, _dataJson).pipe();
  }

 
 /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-06 09:20:49
   * @Descripttion: 
   * @Return: 
   */
  private enumUrl = '/api/materialInoutReq/getEnumList';
  GetEnum(data): Observable<any> {
    let _dataJson = {
      params: {
        ...data
      }
    }
    return this.http.get(this.enumUrl, _dataJson).pipe();
  }
  //#endregion


  //#region 出库
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-06 17:05:40
   * @Descripttion: 出库申请添加
   * @Return: 
   */
  private addOutUrl = '/api/materialInoutReq/out'
  addOut(data): Observable<any> {
    let _dataJson = data
    return this.http.post(this.addOutUrl, _dataJson).pipe();
  }
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-06 17:07:28
   * @Descripttion: 出库申请修改
   * @Return: 
   */
  private editOutUrl = '/api/materialInoutReq/edit_out'
  editOut(data, id): Observable<any> {
    var url = this.editOutUrl + "/" + id;
    let _dataJson = data
    return this.http.put(url, _dataJson).pipe();
  }
  //#endregion
}
